import Vue from 'vue'

// css初始化
import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'

import '@/styles/index.scss' // global css
import 'nprogress/nprogress.css'

import App from './App'
import store from './store'
import router from './router'

import '@/icons' // icon
import '@/permission' // permission control

// 添加自定义指令
// Vue.directive('errorimg',{
//   inserted:function(dom,options) {
//     dom.onerror = function(){
//       dom.src = options.value
//     }
//   }
// })
  // 获取所有内容并放在alldir对象中
import * as alldir from '@/directive'
// console.log(alldir);
  // Object.keys可以获取所有的属性名,并放在数组中
Object.keys(alldir).forEach((item)=>{
  Vue.directive(item,alldir[item])
})

// 导入过滤器
import * as allFilter from '@/filters/index'
// 统一挂载过滤器
Object.keys(allFilter).forEach(item => {
  Vue.filter(item, allFilter[item])
})

// 注册全局插件
import plugin from '@/utils/plugin.js'
Vue.use(plugin)

Vue.use(ElementUI)

Vue.config.productionTip = false

new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
